package main

import (
	"fmt"
	"reflect"
)

//比较俩个相同结构体不同的实例


type Student struct{

	Name string
	Age int
}

type Cat    struct{
	Name string
	Age  int
}


func main() {

	s1 := Student{
		Name: "zhanglin",
		Age:  10,
	}

	s2 := Cat{
		Name: "kity",
		Age: 2,
	}

	t := reflect.TypeOf(s1)

	v1 := reflect.ValueOf(s1)
	v2 := reflect.ValueOf(s2)

	for k := 0; k < t.NumField(); k++ {
		fieldName := t.Field(k).Name
		fmt.Println(v1.FieldByName(fieldName).Interface())
		fmt.Println(v2.FieldByName(fieldName).Interface())
	}

}